package com.qunar.qcf.core.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.qunar.qcf.core.session.IdleStatus;
import com.qunar.qcf.core.session.IoSession;


/**
 * 简单实现了IoHandler
 * An adapter class for {@link IoHandler}.  You can extend this
 * class and selectively override required event handler methods only.  All
 * methods do nothing by default.
 *
 */
public class IoHandlerAdapter implements IoHandler {
    private static final Logger LOGGER = LoggerFactory.getLogger(IoHandlerAdapter.class);

    public void sessionCreated(IoSession session) throws Exception {
        // Empty handler
    }

    public void sessionOpened(IoSession session) throws Exception {
        // Empty handler
    }

    public void sessionClosed(IoSession session) throws Exception {
        // Empty handler
    }

    public void sessionIdle(IoSession session, IdleStatus status)
            throws Exception {
        // Empty handler
    }

    public void exceptionCaught(IoSession session, Throwable cause)
            throws Exception {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("EXCEPTION, please implement "
                    + getClass().getName()
                    + ".exceptionCaught() for proper handling:", cause);
        }
    }

    public void messageReceived(IoSession session, Object message)
            throws Exception {
        // Empty handler
    }

    public void messageSent(IoSession session, Object message) throws Exception {
        // Empty handler
    }
}